home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.6 KB  |  406 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1985-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __EVENTS__
  18. #define __EVENTS__
  19.  
  20. #ifndef __OSUTILS__
  21.     #include <OSUtils.h>
  22. #endif
  23.  
  24. #ifndef __QUICKDRAW__
  25.     #include <Quickdraw.h>
  26. #endif
  27.  
  28. #ifndef __MACTYPES__
  29.     #include <MacTypes.h>
  30. #endif
  31.  
  32. #if !TARGET_OS_MAC || !TARGET_API_MAC_OS8
  33. #ifndef __ENDIAN__
  34.     #include <Endian.h>
  35. #endif
  36.  
  37. #endif  /* !TARGET_OS_MAC || !TARGET_API_MAC_OS8 */
  38.  
  39.  
  40.  
  41. #if PRAGMA_ONCE
  42. #pragma once
  43. #endif
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48.  
  49. #if PRAGMA_IMPORT
  50. #pragma import on
  51. #endif
  52.  
  53. #if PRAGMA_STRUCT_ALIGN
  54.     #pragma options align=mac68k
  55. #elif PRAGMA_STRUCT_PACKPUSH
  56.     #pragma pack(push, 2)
  57. #elif PRAGMA_STRUCT_PACK
  58.     #pragma pack(2)
  59. #endif
  60.  
  61. typedef UInt16                             EventKind;
  62. typedef UInt16                             EventMask;
  63. enum {
  64.     nullEvent                    = 0,
  65.     mouseDown                    = 1,
  66.     mouseUp                        = 2,
  67.     keyDown                        = 3,
  68.     keyUp                        = 4,
  69.     autoKey                        = 5,
  70.     updateEvt                    = 6,
  71.     diskEvt                        = 7,
  72.     activateEvt                    = 8,
  73.     osEvt                        = 15,
  74.     kHighLevelEvent                = 23
  75. };
  76.  
  77. enum {
  78.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  79.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  80.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  81.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  82.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  83.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  84.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  85.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  86.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  87.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  88.     everyEvent                    = 0xFFFF                        /* all of the above*/
  89. };
  90.  
  91. enum {
  92.     charCodeMask                = 0x000000FF,
  93.     keyCodeMask                    = 0x0000FF00,
  94.     adbAddrMask                    = 0x00FF0000,
  95.     osEvtMessageMask            = 0xFF000000
  96. };
  97.  
  98. enum {
  99.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  100.     mouseMovedMessage            = 0x00FA,
  101.     suspendResumeMessage        = 0x0001
  102. };
  103.  
  104. enum {
  105.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  106.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  107. };
  108.  
  109.  
  110. typedef UInt16                             EventModifiers;
  111. enum {
  112.                                                                 /* modifiers */
  113.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  114.     btnStateBit                    = 7,                            /* state of button?*/
  115.     cmdKeyBit                    = 8,                            /* command key down?*/
  116.     shiftKeyBit                    = 9,                            /* shift key down?*/
  117.     alphaLockBit                = 10,                            /* alpha lock down?*/
  118.     optionKeyBit                = 11,                            /* option key down?*/
  119.     controlKeyBit                = 12,                            /* control key down?*/
  120.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  121.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  122.     rightControlKeyBit            = 15                            /* right Control key down?*/
  123. };
  124.  
  125. enum {
  126.     activeFlag                    = 1 << activeFlagBit,
  127.     btnState                    = 1 << btnStateBit,
  128.     cmdKey                        = 1 << cmdKeyBit,
  129.     shiftKey                    = 1 << shiftKeyBit,
  130.     alphaLock                    = 1 << alphaLockBit,
  131.     optionKey                    = 1 << optionKeyBit,
  132.     controlKey                    = 1 << controlKeyBit,
  133.     rightShiftKey                = 1 << rightShiftKeyBit,
  134.     rightOptionKey                = 1 << rightOptionKeyBit,
  135.     rightControlKey                = 1 << rightControlKeyBit
  136. };
  137.  
  138. enum {
  139.     kNullCharCode                = 0,
  140.     kHomeCharCode                = 1,
  141.     kEnterCharCode                = 3,
  142.     kEndCharCode                = 4,
  143.     kHelpCharCode                = 5,
  144.     kBellCharCode                = 7,
  145.     kBackspaceCharCode            = 8,
  146.     kTabCharCode                = 9,
  147.     kLineFeedCharCode            = 10,
  148.     kVerticalTabCharCode        = 11,
  149.     kPageUpCharCode                = 11,
  150.     kFormFeedCharCode            = 12,
  151.     kPageDownCharCode            = 12,
  152.     kReturnCharCode                = 13,
  153.     kFunctionKeyCharCode        = 16,
  154.     kEscapeCharCode                = 27,
  155.     kClearCharCode                = 27,
  156.     kLeftArrowCharCode            = 28,
  157.     kRightArrowCharCode            = 29,
  158.     kUpArrowCharCode            = 30,
  159.     kDownArrowCharCode            = 31,
  160.     kDeleteCharCode                = 127,
  161.     kNonBreakingSpaceCharCode    = 202
  162. };
  163.  
  164.  
  165. struct EventRecord {
  166.     EventKind                         what;
  167.     UInt32                             message;
  168.     UInt32                             when;
  169.     Point                             where;
  170.     EventModifiers                     modifiers;
  171. };
  172. typedef struct EventRecord                EventRecord;
  173. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  174. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  175. #if OPAQUE_UPP_TYPES
  176.     EXTERN_API(FKEYUPP)
  177.     NewFKEYUPP                       (FKEYProcPtr                userRoutine);
  178.  
  179.     EXTERN_API(void)
  180.     DisposeFKEYUPP                   (FKEYUPP                    userUPP);
  181.  
  182.     EXTERN_API(void)
  183.     InvokeFKEYUPP                   (FKEYUPP                    userUPP);
  184.  
  185. #else
  186.     enum { uppFKEYProcInfo = 0x00000000 };                             /* pascal no_return_value Func() */
  187.     #define NewFKEYUPP(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  188.     #define DisposeFKEYUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  189.     #define InvokeFKEYUPP(userUPP)                                     CALL_ZERO_PARAMETER_UPP((userUPP), uppFKEYProcInfo)
  190. #endif
  191. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  192. #define NewFKEYProc(userRoutine)                                 NewFKEYUPP(userRoutine)
  193. #define CallFKEYProc(userRoutine)                                InvokeFKEYUPP(userRoutine)
  194. EXTERN_API( void )
  195. GetMouse                        (Point *                mouseLoc)                            ONEWORDINLINE(0xA972);
  196.  
  197. EXTERN_API( Boolean )
  198. Button                            (void)                                                        ONEWORDINLINE(0xA974);
  199.  
  200. EXTERN_API( Boolean )
  201. StillDown                        (void)                                                        ONEWORDINLINE(0xA973);
  202.  
  203. EXTERN_API( Boolean )
  204. WaitMouseUp                        (void)                                                        ONEWORDINLINE(0xA977);
  205.  
  206. EXTERN_API( UInt32 )
  207. TickCount                        (void)                                                        ONEWORDINLINE(0xA975);
  208.  
  209. EXTERN_API( UInt32 )
  210. KeyTranslate                    (const void *            transData,
  211.                                  UInt16                 keycode,
  212.                                  UInt32 *                state)                                ONEWORDINLINE(0xA9C3);
  213.  
  214. EXTERN_API( UInt32 )
  215. GetCaretTime                    (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F4);
  216.  
  217.  
  218. /* 
  219.     QuickTime 3.0 supports GetKeys() on unix and win32
  220.     But, on little endian machines you will have to be
  221.     careful about bit numberings and/or use a KeyMapByteArray
  222.     instead.
  223. */
  224. #if TARGET_OS_MAC && TARGET_API_MAC_OS8
  225.  
  226. typedef UInt32                             KeyMap[4];
  227. #else
  228. typedef BigEndianLong                     KeyMap[4];
  229. #endif  /* TARGET_OS_MAC && TARGET_API_MAC_OS8 */
  230.  
  231. typedef UInt8                             KeyMapByteArray[16];
  232. EXTERN_API( void )
  233. GetKeys                            (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  234.  
  235. /* Obsolete event types & masks */
  236. enum {
  237.     networkEvt                    = 10,
  238.     driverEvt                    = 11,
  239.     app1Evt                        = 12,
  240.     app2Evt                        = 13,
  241.     app3Evt                        = 14,
  242.     app4Evt                        = 15,
  243.     networkMask                    = 0x0400,
  244.     driverMask                    = 0x0800,
  245.     app1Mask                    = 0x1000,
  246.     app2Mask                    = 0x2000,
  247.     app3Mask                    = 0x4000,
  248.     app4Mask                    = 0x8000
  249. };
  250.  
  251.  
  252. struct EvQEl {
  253.     QElemPtr                         qLink;
  254.     SInt16                             qType;
  255.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  256.     UInt32                             evtQMessage;
  257.     UInt32                             evtQWhen;
  258.     Point                             evtQWhere;
  259.     EventModifiers                     evtQModifiers;
  260. };
  261. typedef struct EvQEl                    EvQEl;
  262. typedef EvQEl *                            EvQElPtr;
  263. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  264. typedef STACK_UPP_TYPE(GetNextEventFilterProcPtr)                 GetNextEventFilterUPP;
  265. #if OPAQUE_UPP_TYPES
  266.     EXTERN_API(GetNextEventFilterUPP)
  267.     NewGetNextEventFilterUPP       (GetNextEventFilterProcPtr userRoutine);
  268.  
  269.     EXTERN_API(void)
  270.     DisposeGetNextEventFilterUPP    (GetNextEventFilterUPP    userUPP);
  271.  
  272.     EXTERN_API(void)
  273.     InvokeGetNextEventFilterUPP       (EventRecord *            theEvent,
  274.                                     Boolean *                result,
  275.                                     GetNextEventFilterUPP    userUPP);
  276.  
  277. #else
  278.     enum { uppGetNextEventFilterProcInfo = 0x000000BF };             /* SPECIAL_CASE_PROCINFO(11) */
  279.     #define NewGetNextEventFilterUPP(userRoutine)                     (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  280.     #define DisposeGetNextEventFilterUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  281.     #define InvokeGetNextEventFilterUPP(theEvent, result, userUPP)     CALL_TWO_PARAMETER_UPP((userUPP), uppGetNextEventFilterProcInfo, (theEvent), (result))
  282. #endif
  283. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  284. #define NewGetNextEventFilterProc(userRoutine)                     NewGetNextEventFilterUPP(userRoutine)
  285. #define CallGetNextEventFilterProc(userRoutine, theEvent, result) InvokeGetNextEventFilterUPP(theEvent, result, userRoutine)
  286.  
  287. typedef GetNextEventFilterUPP             GNEFilterUPP;
  288. EXTERN_API( UInt32 )
  289. GetDblTime                        (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F0);
  290.  
  291. EXTERN_API( void )
  292. SetEventMask                    (EventMask                 value)                                TWOWORDINLINE(0x31DF, 0x0144);
  293.  
  294. #if CALL_NOT_IN_CARBON
  295. EXTERN_API( QHdrPtr )
  296. GetEvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  297.  
  298.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  299.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  300.                                                                                             #endif
  301. EXTERN_API( OSErr )
  302. PPostEvent                        (EventKind                 eventCode,
  303.                                  UInt32                 eventMsg,
  304.                                  EvQElPtr *                qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  305.  
  306. #endif  /* CALL_NOT_IN_CARBON */
  307.  
  308. EXTERN_API( Boolean )
  309. GetNextEvent                    (EventMask                 eventMask,
  310.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA970);
  311.  
  312. EXTERN_API( Boolean )
  313. WaitNextEvent                    (EventMask                 eventMask,
  314.                                  EventRecord *            theEvent,
  315.                                  UInt32                 sleep,
  316.                                  RgnHandle                 mouseRgn) /* can be NULL */            ONEWORDINLINE(0xA860);
  317.  
  318. EXTERN_API( Boolean )
  319. EventAvail                        (EventMask                 eventMask,
  320.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA971);
  321.  
  322.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  323.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  324.                                                                                             #endif
  325. EXTERN_API( OSErr )
  326. PostEvent                        (EventKind                 eventNum,
  327.                                  UInt32                 eventMsg)                            ONEWORDINLINE(0xA02F);
  328.  
  329. /*
  330.       For Carbon, use EventAvail, TickCount, GetGlobalMouse,
  331.       GetKeys, or GetCurrentKeyModifiers instead of
  332.       OSEventAvail, and use GetNextEvent or WaitNextEvent
  333.       instead of GetOSEvent.
  334. */
  335.  
  336. #if CALL_NOT_IN_CARBON
  337.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  338.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  339.                                                                                             #endif
  340. EXTERN_API( Boolean )
  341. OSEventAvail                    (EventMask                 mask,
  342.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA030, 0x5240);
  343.  
  344.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  345.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  346.                                                                                             #endif
  347. EXTERN_API( Boolean )
  348. GetOSEvent                        (EventMask                 mask,
  349.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA031, 0x5240);
  350.  
  351. #endif  /* CALL_NOT_IN_CARBON */
  352.  
  353. EXTERN_API( void )
  354. FlushEvents                        (EventMask                 whichMask,
  355.                                  EventMask                 stopMask)                            TWOWORDINLINE(0x201F, 0xA032);
  356.  
  357. #if CALL_NOT_IN_CARBON
  358. EXTERN_API( void )
  359. SystemClick                        (const EventRecord *    theEvent,
  360.                                  WindowPtr                 theWindow)                            ONEWORDINLINE(0xA9B3);
  361.  
  362. EXTERN_API( void )
  363. SystemTask                        (void)                                                        ONEWORDINLINE(0xA9B4);
  364.  
  365. EXTERN_API( Boolean )
  366. SystemEvent                        (const EventRecord *    theEvent)                            ONEWORDINLINE(0xA9B2);
  367.  
  368. #endif  /* CALL_NOT_IN_CARBON */
  369.  
  370. #if OLDROUTINENAMES
  371. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  372. #endif  /* OLDROUTINENAMES */
  373.  
  374. /*
  375.       GetGlobalMouse and GetCurrentKeyModifiers
  376.       are only available as part of the Carbon API.
  377. */
  378.  
  379. EXTERN_API( void )
  380. GetGlobalMouse                    (Point *                globalMouse);
  381.  
  382. EXTERN_API( UInt32 )
  383. GetCurrentKeyModifiers            (void);
  384.  
  385.  
  386. #if PRAGMA_STRUCT_ALIGN
  387.     #pragma options align=reset
  388. #elif PRAGMA_STRUCT_PACKPUSH
  389.     #pragma pack(pop)
  390. #elif PRAGMA_STRUCT_PACK
  391.     #pragma pack()
  392. #endif
  393.  
  394. #ifdef PRAGMA_IMPORT_OFF
  395. #pragma import off
  396. #elif PRAGMA_IMPORT
  397. #pragma import reset
  398. #endif
  399.  
  400. #ifdef __cplusplus
  401. }
  402. #endif
  403.  
  404. #endif /* __EVENTS__ */
  405.  
  406.